<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>设置培训人员状态</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../../static/css/font.css" th:href="@{/css/font.css}">
    <link rel="stylesheet" href="../../static/css/xadmin.css" th:href="@{/css/xadmin.css}">
    <script src="../../static/lib/layui/layui.js" charset="utf-8" th:src="@{/lib/layui/layui.js}"></script>
    <script type="text/javascript" src="../../static/js/xadmin.js" th:src="@{/js/xadmin.js}"></script>
    <script src="../../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item" pane="">
                            <label class="layui-form-label">培训状态</label>
                            <div class="layui-input-block" id="status">

                            </div>
                        </div>
                        <div class="layui-form-item" style="display: flex;justify-content: center;">
                            <button class="layui-btn" lay-submit="" lay-filter="setstatus" type="button">确认修改</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script th:inline="NONE">


    layui.use( 'form', function () {
        var form = layui.form;
        var trainingProcess = window.location.href.split("?")[1].split("&")[1].split("=")[1];
        var Status = trainingProcess
        var html =''
        if (Status == 0){
            html +='<input type="radio" name="status" value="0" title="正在培训" checked="">\n' +
                '                                <input type="radio" name="status" value="1" title="未通过">\n' +
                '                                <input type="radio" name="status" value="2" title="已完成">'
        }else if (Status == 1){
            html +='<input type="radio" name="status" value="0" title="正在培训" >\n' +
                '                                <input type="radio" name="status" value="1" title="未通过" checked="">\n' +
                '                                <input type="radio" name="status" value="2" title="已完成">'
        }else if (Status == 2){
            html +='<input type="radio" name="status" value="0" title="正在培训" >\n' +
                '                                <input type="radio" name="status" value="1" title="未通过" >\n' +
                '                                <input type="radio" name="status" value="2" title="已完成" checked="">'
        }
        $('#status').html(html);
        form.render();

        form.on('submit(setstatus)',function (data) {
            var userTrainingRecordId  = window.location.href.split("?")[1].split("=")[1].split("&")[0];
            var result = data.field
            $.ajax({
                url: '/v1/training/updateUserTrainingRecordProcess',
                type: 'post',
                dataType: 'json',
                async: true,
                data: {
                    process : result.status,
                    userTrainingRecordId:userTrainingRecordId
                },
                success:function (data) {
                    layer.msg('设置成功!', {
                        icon: 1,
                        time: 1000
                    });
                },
                error:function (data) {
                    layer.msg('设置失败!', {
                        icon: 2,
                        time: 1000
                    });
                }
            })
        })

    });

</script>
</body>
</html>